home *** CD-ROM | disk | FTP | other *** search
/ Sun Solutions 1997 April to September / Sun Solutions CD - APR '97 - SEP '97 (704-3778-12 Rev. H)(Sun Microsystems, Inc.)(1997).iso / products / bin / httpd / Solaris_2 / catIPX.Sol1 < prev    next >
Text File  |  1995-09-18  |  5KB  |  182 lines

  1. #!/bin/csh 
  2. # below is a scrpit launched by catIPX.pl from CDware 
  3. # It ultimately generates a query page to be 
  4. # displayed by the cgi-bin/catIPX.pl script.
  5. # Jun 6, 1995 Marc Sacoolas
  6.  
  7. setenv ONLY_ONE spam
  8.  
  9. set testdrvflg = 0
  10. set installflg = 0
  11. set osflg = 0
  12.  
  13. #
  14. # Get search string, filter-type and category
  15. #
  16.  
  17. set keyword = `awk -F^ '{ print $1 }' /tmp/httpd/tmp `
  18. set install = `awk -F^ '{ print $2 }' /tmp/httpd/tmp `
  19. set testdrive = `awk -F^ '{ print $3 }' /tmp/httpd/tmp `
  20. set ostype = `awk -F^ '{ print $4 }' /tmp/httpd/tmp | sed 's/ //g'`
  21.  
  22. # clear temporary files 
  23.  
  24. rm /tmp/httpd/tmppage.html
  25. #touch /tmp/httpd/tmppage.html
  26. rm /tmp/httpd/top
  27. touch /tmp/httpd/top
  28.  
  29. #
  30. # goto index.html directory and grep files for keyword --main list
  31. #
  32.  
  33. cd ../../../../.products
  34.  
  35.  
  36. foreach dir (`ls`)
  37.  
  38. if ( $dir == "hotjava" || $dir == "tmp" || $dir == "CDware" )  next 
  39.  
  40. # set flags for filters
  41. if ( $ostype != "OSType" ) then 
  42.  
  43.         set osflg = ` nawk -F^ ' { if (NR == 2) exit; if ( $3 ~ /'"$ostype"'/ ) {print "0"} else {print "1"} }' $dir/_info `
  44.  
  45. endif 
  46.   
  47.  
  48. if ( $testdrive == "testdrive" ) then
  49.  
  50.         set testdrvflg = ` awk -F^ ' { if (NR == 2) exit; if ( $3 ~ /'"$testdrive"'/ ) {print "0"} else {print "1"} }' $dir/_info `
  51.  
  52. endif    
  53.  
  54.  
  55. if ( $install == "install" ) then 
  56.  
  57.         set installflg = ` awk -F^ ' { if (NR == 2) exit; if ( $3 ~ /'"$install"'/ ) {print "0"} else {print "1"} }' $dir/_info `
  58.  
  59. endif
  60.  
  61. # check to see if a blank query is given - make it *all*
  62.  
  63. if ( $keyword != "" ) then
  64.  
  65. set yes  = `grep -il $keyword $dir/index.html ` 
  66.  
  67. else 
  68.  
  69. set yes = "spam"
  70.  
  71. endif
  72.  
  73. if ( $yes != "" && $installflg == "0" && $testdrvflg == "0" && $osflg == "0") then
  74.  
  75.  
  76. # read in company name and log
  77.  
  78. nawk -F^ ' { if (NR == 1) { \
  79. print ""$1"^"$2"^'"$dir"'^"} \
  80. }' $dir/_info  >> /tmp/httpd/top 
  81.  
  82. endif
  83.  
  84. set testdrvflg = 0
  85. set installflg = 0
  86.  
  87. end
  88.  
  89. sort -o /tmp/httpd/top.sort /tmp/httpd/top 
  90.  
  91. cd ../.products/.bin/httpd/cgi-bin
  92.  
  93. # see if *filter* exists
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102. #
  103. # creat new page based on resource file generated above 
  104. #
  105.  
  106.  
  107. if ( -z /tmp/httpd/top.sort ) then
  108. cat head.html > /tmp/httpd/tmppage.html
  109.     echo "<p>" >> /tmp/httpd/tmppage.html
  110.     echo "<h1>Try Again</H1>" >> /tmp/httpd/tmppage.html
  111. else 
  112.  
  113. cat head.html > /tmp/httpd/tmppage.html
  114.  
  115. # get number of answers and print
  116. set return = `grep -c ^ /tmp/httpd/top`
  117.  
  118. # if only one reslut, go there
  119.  
  120. if ( $return == 1 ) then
  121.  
  122. touch /tmp/httpd/only_one
  123. exit 0
  124.  
  125. endif
  126.  
  127.  
  128. if ( $return == 1 ) then
  129. set booths = "Company."
  130. else
  131. set booths = "Companies."
  132. endif
  133. echo "<I> Your search of  </I>'<B>Companies</B>' <I>for  </I>'<B>$keyword</B>' <I>produced  </I><B>$return</B> <I> $booths</I>" >> /tmp/httpd/tmppage.html
  134. echo "<p>" >> /tmp/httpd/tmppage.html
  135.  
  136. # make main txt
  137.  
  138. echo "</pre>" >> /tmp/httpd/tmppage.html
  139. echo "<DL>" >> /tmp/httpd/tmppage.html
  140. echo '<hr>' >> /tmp/httpd/tmppage.html
  141. echo '<p>' >> /tmp/httpd/tmppage.html
  142.  
  143. # only include if over some ammount
  144. if ( $return >= 2 ) then 
  145. echo '<B><FONT size="-1">' /tmp/httpd/tmppage.html
  146. echo '<B>Search for--</b><A HREF="/tmp/httpd/tmppage.html#A">A</A> <A HREF="/tmp/httpd/tmppage.html#B">B</A> <A HREF="/tmp/httpd/tmppage.html#C">C</A> <A HREF="/tmp/httpd/tmppage.html#D">D</A>' >> /tmp/httpd/tmppage.html
  147. echo '<A HREF="/tmp/httpd/tmppage.html#E">E</A> <A HREF="/tmp/httpd/tmppage.html#F">F</A> <A HREF="/tmp/httpd/tmppage.html#G">G</A> <A HREF="/tmp/httpd/tmppage.html#H">H</A>' >> /tmp/httpd/tmppage.html
  148. echo '<A HREF="/tmp/httpd/tmppage.html#I">I</A> <A HREF="/tmp/httpd/tmppage.html#J">J</A> <A HREF="/tmp/httpd/tmppage.html#K">K</A> <A HREF="/tmp/httpd/tmppage.html#L">L</A>' >> /tmp/httpd/tmppage.html
  149. echo '<A HREF="/tmp/httpd/tmppage.html#M">M</A> <A HREF="/tmp/httpd/tmppage.html#N">N</A> <A HREF="/tmp/httpd/tmppage.html#O">O</A> <A HREF="/tmp/httpd/tmppage.html#P">P</A>' >> /tmp/httpd/tmppage.html
  150. echo '<A HREF="/tmp/httpd/tmppage.html#Q">Q</A> <A HREF="/tmp/httpd/tmppage.html#R">R</A> <A HREF="/tmp/httpd/tmppage.html#S">S</A> <A HREF="/tmp/httpd/tmppage.html#T">T</A>' >> /tmp/httpd/tmppage.html
  151. echo '<A HREF="/tmp/httpd/tmppage.html#U">U</A> <A HREF="/tmp/httpd/tmppage.html#V">V</A> <A HREF="/tmp/httpd/tmppage.html#W">W</A> <A HREF="/tmp/httpd/tmppage.html#X">X</A>' >> /tmp/httpd/tmppage.html
  152. echo '<A HREF="/tmp/httpd/tmppage.html#Y">Y</A> <A HREF="/tmp/httpd/tmppage.html#Z">Z</A>' >> /tmp/httpd/tmppage.html
  153. echo '</FONT></B>' >> /tmp/httpd/tmppage.html
  154. echo '<hr>' >> /tmp/httpd/tmppage.html
  155.  
  156. endif
  157.  
  158. nawk -F^ ' BEGIN {i=65;s=0;letter ="^A.*";rletter = "A"} \
  159. { comp = $1\
  160. if ( comp !~ letter ) {\
  161. for ( x=i;x<=100; ++x ){\
  162. letter = sprintf("^%c.*", x)\
  163. rletter = sprintf("%c", x)\
  164. if ( comp ~ letter ) {i=x;s=0;break}\
  165. }\
  166. }\
  167. if ( comp ~ letter && s==0 ) {\
  168. print "<DT><A NAME=\""rletter"\"><B>"rletter"</B><DD></A><a href=http://localhost:7999/"$3" <b><b>"$1"</b></b></a>"$2"<br>";s=2 \
  169. }\
  170. if ( comp ~ letter && s==1) {\
  171. print "      <DD><a href=http://localhost:7999/"$3" <b><b>"$1"</b></b></a>"$2"<br>"\
  172. }\
  173. s=1\
  174. }' /tmp/httpd/top.sort >> /tmp/httpd/tmppage.html
  175.  
  176. endif
  177.  
  178. cat tail.html >> /tmp/httpd/tmppage.html
  179.  
  180.  
  181. exit 0
  182.